#include "pagejump.h"

PageJump::PageJump(QWidget *parent) : QWidget(parent),
    home(NULL),first(NULL),second(NULL)
{

}

PageJump::~PageJump()
{

}

void PageJump::show()
{
    gotoMain();
}

void PageJump::gotoMain()
{
    if(home==NULL)
    {
        home = new MainWidget();
        connect(home,&MainWidget::mainToFirst,
                this,&PageJump::gotoFirst);
        connect(home,&MainWidget::mainToSecond,
                this,&PageJump::gotoSecond);
    }
    home->show();

}

void PageJump::gotoFirst()
{
    if(first ==NULL)
    {
        first = new FirstWidget();
        connect(first,&FirstWidget::firstToMain,
                this,&PageJump::gotoMain);
        connect(first,&FirstWidget::firstToSecond,
                this,&PageJump::gotoSecond);
    }
    first->show();
}

void PageJump::gotoSecond()
{
    if(second ==NULL)
    {
        second = new SecondWidget();
        connect(second,&SecondWidget::secondToMain,
                this,&PageJump::gotoMain);
        connect(second,&SecondWidget::secondToFirst,
                this,&PageJump::gotoFirst);
    }
    second->show();
}
